<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
  <Type Name="alloc::vec::Vec&lt;*&gt;">
    <DisplayString>{{ len={len} }}</DisplayString>
    <Expand>
      <Item Name="[len]" ExcludeView="simple">len</Item>
      <Item Name="[capacity]" ExcludeView="simple">buf.cap</Item>
      <ArrayItems>
        <Size>len</Size>
        <ValuePointer>buf.ptr.pointer.pointer</ValuePointer>
      </ArrayItems>
    </Expand>
  </Type>
  <Type Name="alloc::collections::vec_deque::VecDeque&lt;*&gt;">
    <DisplayString>{{ len={len} }}</DisplayString>
    <Expand>
      <Item Name="[len]" ExcludeView="simple">len</Item>
      <Item Name="[capacity]" ExcludeView="simple">buf.cap</Item>
      <CustomListItems>
        <Variable Name="i" InitialValue="0" />
        <Size>len</Size>
        <Loop>
          <If Condition="i == len">
            <Break/>
          </If>
          <Item>buf.ptr.pointer.pointer[(i + head) % buf.cap]</Item>
          <Exec>i = i + 1</Exec>
        </Loop>
      </CustomListItems>
    </Expand>
  </Type>
  <Type Name="alloc::collections::linked_list::LinkedList&lt;*&gt;">
    <DisplayString>{{ len={len} }}</DisplayString>
    <Expand>
      <LinkedListItems>
        <Size>len</Size>
        <HeadPointer>*(alloc::collections::linked_list::Node&lt;$T1&gt; **)&amp;head</HeadPointer>
        <NextPointer>*(alloc::collections::linked_list::Node&lt;$T1&gt; **)&amp;next</NextPointer>
        <ValueNode>element</ValueNode>
      </LinkedListItems>
    </Expand>
  </Type>
  <Type Name="alloc::string::String">
    <DisplayString>{(char*)vec.buf.ptr.pointer.pointer,[vec.len]s8}</DisplayString>
    <StringView>(char*)vec.buf.ptr.pointer.pointer,[vec.len]s8</StringView>
    <Expand>
      <Item Name="[len]" ExcludeView="simple">vec.len</Item>
      <Item Name="[capacity]" ExcludeView="simple">vec.buf.cap</Item>
      <Synthetic Name="[chars]">
        <DisplayString>{(char*)vec.buf.ptr.pointer.pointer,[vec.len]s8}</DisplayString>
        <Expand>
          <ArrayItems>
            <Size>vec.len</Size>
            <ValuePointer>(char*)vec.buf.ptr.pointer.pointer</ValuePointer>
          </ArrayItems>
        </Expand>
      </Synthetic>
    </Expand>
  </Type>

  <!--
      The display string for Rc, Arc, etc is optional because the expression cannot be evaluated
      if the pointee is unsized (i.e. if `ptr.pointer` is a fat pointer).

      There are also two versions for the reference count fields, one for sized and one for
      dyn pointees.

      Rc<[T]> and Arc<[T]> are handled separately altogether so we can actually show
      the slice values.
  -->
  <!-- alloc::rc::Rc<T> -->
  <Type Name="alloc::rc::Rc&lt;*&gt;">
    <DisplayString Optional="true">{ptr.pointer->value}</DisplayString>
    <Expand>
      <!-- thin -->
      <ExpandedItem Optional="true">ptr.pointer->value</ExpandedItem>
      <Item Name="[Reference count]" Optional="true">ptr.pointer->strong</Item>
      <Item Name="[Weak reference count]" Optional="true">ptr.pointer->weak</Item>

      <!-- dyn -->
      <Item Name="[Reference count]" Optional="true">ptr.pointer.pointer->strong</Item>
      <Item Name="[Weak reference count]" Optional="true">ptr.pointer.pointer->weak</Item>
    </Expand>
  </Type>

  <!-- alloc::rc::Rc<[T]> -->
  <Type Name="alloc::rc::Rc&lt;slice2$&lt;*&gt; &gt;">
    <DisplayString>{{ len={ptr.pointer.length} }}</DisplayString>
    <Expand>
      <Item Name="[Length]" ExcludeView="simple">ptr.pointer.length</Item>
      <Item Name="[Reference count]">ptr.pointer.data_ptr->strong</Item>
      <Item Name="[Weak reference count]">ptr.pointer.data_ptr->weak</Item>
      <ArrayItems>
        <Size>ptr.pointer.length</Size>
        <!-- We add +2 to the data_ptr in order to skip the ref count fields in the RcBox -->
        <ValuePointer>($T1*)(((size_t*)ptr.pointer.data_ptr) + 2)</ValuePointer>
      </ArrayItems>
    </Expand>
  </Type>

  <!-- alloc::rc::Weak<T> -->
  <Type Name="alloc::rc::Weak&lt;*&gt;">
    <DisplayString Optional="true">{ptr.pointer->value}</DisplayString>
    <Expand>
      <!-- thin -->
      <ExpandedItem Optional="true">ptr.pointer->value</ExpandedItem>
      <Item Name="[Reference count]" Optional="true">ptr.pointer->strong</Item>
      <Item Name="[Weak reference count]" Optional="true">ptr.pointer->weak</Item>

      <!-- dyn -->
      <Item Name="[Reference count]" Optional="true">ptr.pointer.pointer->strong</Item>
      <Item Name="[Weak reference count]" Optional="true">ptr.pointer.pointer->weak</Item>
    </Expand>
  </Type>

  <!-- alloc::rc::Weak<[T]> -->
  <Type Name="alloc::rc::Weak&lt;slice2$&lt;*&gt; &gt;">
    <DisplayString>{{ len={ptr.pointer.length} }}</DisplayString>
    <Expand>
      <Item Name="[Length]" ExcludeView="simple">ptr.pointer.length</Item>
      <Item Name="[Reference count]">ptr.pointer.data_ptr->strong</Item>
      <Item Name="[Weak reference count]">ptr.pointer.data_ptr->weak</Item>
      <ArrayItems>
        <Size>ptr.pointer.length</Size>
        <ValuePointer>($T1*)(((size_t*)ptr.pointer.data_ptr) + 2)</ValuePointer>
      </ArrayItems>
    </Expand>
  </Type>

  <!-- alloc::sync::Arc<T> -->
  <Type Name="alloc::sync::Arc&lt;*&gt;">
    <DisplayString Optional="true">{ptr.pointer->data}</DisplayString>
    <Expand>
      <!-- thin -->
      <ExpandedItem Optional="true">ptr.pointer->data</ExpandedItem>
      <Item Name="[Reference count]" Optional="true">ptr.pointer->strong</Item>
      <Item Name="[Weak reference count]" Optional="true">ptr.pointer->weak</Item>

      <!-- dyn -->
      <Item Name="[Reference count]" Optional="true">ptr.pointer.pointer->strong</Item>
      <Item Name="[Weak reference count]" Optional="true">ptr.pointer.pointer->weak</Item>
    </Expand>
  </Type>

  <!-- alloc::sync::Arc<[T]> -->
  <Type Name="alloc::sync::Arc&lt;slice2$&lt;*&gt; &gt;">
    <DisplayString>{{ len={ptr.pointer.length} }}</DisplayString>
    <Expand>
      <Item Name="[Length]" ExcludeView="simple">ptr.pointer.length</Item>
      <Item Name="[Reference count]">ptr.pointer.data_ptr->strong</Item>
      <Item Name="[Weak reference count]">ptr.pointer.data_ptr->weak</Item>
      <ArrayItems>
        <Size>ptr.pointer.length</Size>
        <ValuePointer>($T1*)(((size_t*)ptr.pointer.data_ptr) + 2)</ValuePointer>
      </ArrayItems>
    </Expand>
  </Type>

  <!-- alloc::sync::Weak<T> -->
  <Type Name="alloc::sync::Weak&lt;*&gt;">
    <DisplayString Optional="true">{ptr.pointer->data}</DisplayString>
    <Expand>
      <!-- thin -->
      <ExpandedItem Optional="true">ptr.pointer->data</ExpandedItem>
      <Item Name="[Reference count]" Optional="true">ptr.pointer->strong</Item>
      <Item Name="[Weak reference count]" Optional="true">ptr.pointer->weak</Item>

      <!-- dyn -->
      <Item Name="[Reference count]" Optional="true">ptr.pointer.pointer->strong</Item>
      <Item Name="[Weak reference count]" Optional="true">ptr.pointer.pointer->weak</Item>
    </Expand>
  </Type>

  <!-- alloc::sync::Weak<[T]> -->
  <Type Name="alloc::sync::Weak&lt;slice2$&lt;*&gt; &gt;">
    <DisplayString>{{ len={ptr.pointer.length} }}</DisplayString>
    <Expand>
      <Item Name="[Length]" ExcludeView="simple">ptr.pointer.length</Item>
      <Item Name="[Reference count]">ptr.pointer.data_ptr->strong</Item>
      <Item Name="[Weak reference count]">ptr.pointer.data_ptr->weak</Item>
      <ArrayItems>
        <Size>ptr.pointer.length</Size>
        <ValuePointer>($T1*)(((size_t*)ptr.pointer.data_ptr) + 2)</ValuePointer>
      </ArrayItems>
    </Expand>
  </Type>
</AutoVisualizer>
